//Accepted
#include <cstdio>

int sum, k, i, j, l, n, m, ss;
char s[150][151];

int main (){
	scanf("%d%d", &n, &m);
	for(i=0;i<n;++i)scanf("%s", s[i]);
	ss=1;
	k=l=sum=0;
	for(j=0,i=0; i<n ; ++i, ss *= -1){
		for(j+=ss;(j<m)&&(j>-1);j+=ss){
			k+=((ss<0)?((j<l)?1:-1):((j>l)?1:-1));
			if(s[i][j]=='W'){
				sum+=k;
				l=j;
				k=0;
			}
		}
		k+=2;
	}
	printf("%d\n", sum);
	return 0;
}
